import Vue from 'vue'
import VueRouter from 'vue-router'
// import Login from '@/views/Login'
// import Layout from '@/views/Layout'
// import Home from '@/views/Home'
// import User from '@/views/User'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/layout'
  },

  {
    path: '/login',
    component: () => import('@/views/Login')// 懒加载
  },
  {
    path: '/layout',
    component: () => import('@/views/Layout'), // 懒加载
    redirect: '/layout/home',
    children: [
      {
        path: 'home',
        meta: { scrollTop: 0 },
        component: () => import('@/views/Home')// 懒加载
      },
      {
        path: 'user',
        component: () => import('@/views/User')// 懒加载
      }
    ]
  },
  { // 搜索界面,一级标题
    path: '/search',
    component: () => import('@/views/Search')// 懒加载
  },
  { // 结果页,一级标题
    path: '/search/:keyWords', // 路径上传具体值到这里
    component: () => import('@/views/SearchResult')// 懒加载
  },
  { // 文章详情,一级标题
    path: '/article_detail', // 路径上传具体值到这里
    component: () => import('@/views/ArticleDetail')// 懒加载
  },
  { // 用户编辑资料界面
    path: '/user_edit',
    component: () => import('@/views/User/UserEdit')// 懒加载
  },
  { // 配置小思同学的路由
    path: '/chat',
    component: () => import('@/views/User/Chat')
  }

]

const router = new VueRouter({
  routes
})

export default router
